<!-- 修改密码 -->
<template>
	<view class="set-bgd">
		<!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">修改密码</block>
		</cu-custom> -->
		<view class="modify-bigbox">
			<input type="password" v-model="oldPass" class="sty-inp" placeholder-class="place-sty" placeholder="请输入原密码">
			<input type="password" v-model="newPass" class="sty-inp" placeholder-class="place-sty" placeholder="请输入新密码">
			<input type="password" v-model="affirmPass" class="sty-inp" placeholder-class="place-sty" placeholder="确认新密码">
		</view>
		<view class="affirm" @click="handleClickChange">确认</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldPass: '',
				newPass: '',
				affirmPass: '',
				token: '',
			}
		},
		methods: {
			async handleClickChange() {
				// 取token
				try {
					const value = uni.getStorageSync('login_key');
					if (value) {
						this.token = value;
					}
				} catch (e) {
					// error
				}
				let url = this.ServicesApi.changepassword;
				let data = {
					old_password: this.oldPass,
					password: this.newPass,
					repeat: this.affirmPass
				};
				let result = await this.Services.post(url, data);
				if (result.code == this.StatusCode.SUCCESS_CODE) {
					uni.showToast({
						icon: 'none',
						title: result.msg,
					});
					uni.navigateTo({
						url: '/pages/login/login'
					});
				} else {
					uni.showToast({
						icon: 'none',
						title: result.msg,
					});
				}

				// uni.request({
				//     url: this.ServicesApi.changepassword,
				// 	method:'POST',
				//     data: {
				// 		token:this.token,
				//         old_password:this.oldPass,
				// 		password:this.newPass,
				// 		repeat:this.affirmPass
				//     },
				// 	header: {

				// 		"content-type":"application/x-www-form-urlencoded"
				// 	},
				//     success: (res) => {
				//         // console.log(res.data);
				//         uni.navigateTo({
				//             url:'/pages/login/login'
				//         });
				//         uni.showToast({
				//         	title: '修改成功'
				//         });
				//     }
				// });
			}
		}
	}
</script>

<style scoped lang="stylus">
	.set-bgd {
		height: 100%;
		width: 100%;
		background: #fff;
		position absolute;
	}

	.modify-bigbox {
		padding: 216upx 60upx 0 60upx;
		background-image: url('~@/static/img/img_bg_login_top.png');
		background-size: auto 200rpx;
		background-position: right top;
		background-repeat: no-repeat;
		background-color: #FFFFFF;

		.sty-inp {
			border-bottom: 2upx solid #D8D8D8;
			font-size: 36upx;
			margin-top: 20upx;
			color: #999;
			height: 100upx;
		}
	}

	.affirm {
		height: 90upx;
		width: 620upx;
		background: linear-gradient(270deg, rgba(0, 106, 231, 1) 0%, rgba(66, 157, 255, 1) 100%);
		text-align: center;
		line-height: 90upx;
		color: #fff;
		font-size: 32upx;
		border-radius: 4upx;
		margin: 80upx auto;
	}
</style>
